layui.define(['Mock', 'apiAuth', 'qs'], function (exports) {
	var Mock = layui.Mock,
		api = layui.apiAuth,
		qs = layui.qs;

	function authMock() {
		Mock.setup({
			timeout: '50-100'
		})

		/**
		 * @author: ares
		 * @date: 2020/2/2 19:24
		 * @description: 登录
		 */
		Mock.mock(RegExp(api.login + '[^\.]*$'), 'post', function (options) {
			var params = qs.parse(options.url.split('?')[1]),
				body = JSON.parse(options.body),
				result = Mock.mock({
					data: {
						id: 1,
						name: 'admin',
						phone: 13166103561,
						birthday: '@data',
						email: '@email',
						IDCard: '@ID',
						zip: '@zip',
						county: '@county(true)'
					}
				});
			if (body.account == 'admin' && body.password == 'admin' && body.code == 'jgmxj') {
				result.code = 2000;
				result.msg = '登录成功';
			} else {
				result.code = 1000;
				result.data = null;
				result.msg = '用户名/密码/验证码错误';
			}
			return result;
		})

		/**
		 * @author: ares
		 * @date: 2020/2/2 20:49
		 * @description: 退出登录
		 */
		Mock.mock(RegExp(api.logout + '[^\.]*$'), function (options) {
			return {
				code: 2000,
				msg: '退出成功'
			};
		})
	}

	exports("authMock", authMock);
})